function jsonToXML(asPlain){
	this.xml = "";
	this.OPEN = asPlain ? "&lt;" : "<";
	this.C_OPEN = asPlain ? "&lt;/" : "</";
	this.CLOSE = asPlain ? "&gt;" : ">";
	this.S_CLOSE = asPlain ? " /&gt;" : " />";
	var base = this;
	
	this.manage$Attr = function(attrObject){
		var attr = "";
		for(name in attrObject){
			attr += " " + name + " = '" + attrObject[name] + "'";
		}
		return attr;
	}

	this.manage$Node = function(name, value){
		if(name == "$attr")
			return "";
		if(name == "$text")
			return value;
		if(name == "$self")
			return "/>";
	}

	this.manageNode = function(name, value){
		var xml = "";
		xml += "\n" + base.OPEN + name + base.manage$Attr(value.$attr);
		if(!value.$self){
			xml += base.CLOSE;
		}
		
		xml += base.process(value);
		
		if(!value.$self){
			xml += base.C_OPEN + name + base.CLOSE;
		}
		
		return xml;
	}
	
	this.process = function(jsonObject){
		var xml = "";
		for(name in jsonObject){
			var actual = jsonObject[name];

			if(name[0] == "$")
				xml += base.manage$Node(name, actual);
			else
				xml += base.manageNode(name, actual);
		}
		
		return xml;
	}
}
